package com.showde.shoppingmall.netentity;

import android.util.Log;

import com.kim.net.NetEntity;
import com.showde.shoppingmall.ShoppingMallApplication;
import com.showde.shoppingmall.utils.URLS;

public class ProductCollectionEntity extends NetEntity {

	public enum CollectionOperatorType {
		add, query, delete;
	}

	private static final String TAG = "ProductCollectionEntity";

	/**
	 * 
	 */
	private static final long serialVersionUID = 8857975721126008150L;

	private String productId; // 商品ID

	private boolean isQueryProductCollection = false;

	private CollectionOperatorType collectionOperatorType;

	/**
	 * 添加或删除收藏
	 * 
	 * @param productId
	 */
	public ProductCollectionEntity(String productId,
			CollectionOperatorType collectionOperatorType) {
		this.productId = productId;
		this.collectionOperatorType = collectionOperatorType;
		this.url = URLS.URL_PRODUCT_COLLECTION_DELETE;
	}

	public ProductCollectionEntity() {
		super();
		this.url = URLS.URL_PRODUCT_COLLECTION_QUERY;
		isQueryProductCollection = true;
	}

	@Override
	public String getSendData() {
		String userAccount = ShoppingMallApplication.userSession
				.getSessionUser().getUserAccount();
		String password = ShoppingMallApplication.userSession.getSessionUser()
				.getUserPassword();
		String sendData = null;

		if (isQueryProductCollection) {
			sendData = "{\"Account\":\"" + userAccount + "\",\"Password\":\""
					+ password + "\"}";
		} else if (CollectionOperatorType.add.equals(collectionOperatorType)) {
			sendData = "{\"GoodsId\":" + productId + ",\"Account\":\""
					+ userAccount + "\",\"Password\":\"" + password + "\"}";
		} else if (CollectionOperatorType.delete.equals(collectionOperatorType)) {
			sendData = "{\"Id\":" + productId + "}";
		}

		Log.d(TAG, "sendData:" + sendData);

		return sendData;
	}

	@Override
	protected void init() {
		this.url = URLS.URL_PRODUCT_COLLECTION;
	}

	@Override
	protected void initHttpHeader() {
		// TODO Auto-generated method stub

	}

}
